﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

using System.Text;
namespace System.Data.SugarClient
{
	public class SugarParameterCollection : DbParameterCollection
	{

		private IList<SugarParameter> _parameters = new List<SugarParameter>();

		public override int Count
		{
			get { return _parameters.Count; }
		}

		public override int Add(object value)
		{
			if (value is SugarParameter) 
			{
				_parameters.Add(value as SugarParameter);
				return _parameters.Count -1;
			}
			else
			{
				throw new SugarException();
			}
		}

		public override void AddRange(Array values)
		{
			throw new NotImplementedException();
		}

		public override void Clear()
		{
			throw new NotImplementedException();
		}

		public override bool Contains(string value)
		{
			throw new NotImplementedException();
		}

		public override bool Contains(object value)
		{
			if (value is SugarParameter) return _parameters.Contains(value as SugarParameter);
			return false;
		}

		public override void CopyTo(Array array, int index)
		{
			throw new NotImplementedException();
		}

		public override System.Collections.IEnumerator GetEnumerator()
		{
			return _parameters.GetEnumerator();
		}

		protected override DbParameter GetParameter(string parameterName)
		{
			return this.GetParameter(this.IndexOf(parameterName));
		}

		protected override DbParameter GetParameter(int index)
		{
			return this._parameters[index];
		}

		public override int IndexOf(string parameterName)
		{
			foreach (SugarParameter paramer in this._parameters) { if (paramer.ParameterName.Equals(parameterName)) return this._parameters.IndexOf(paramer); }
			return -1;
		}

		public override int IndexOf(object value)
		{
			throw new NotImplementedException();
		}

		public override void Insert(int index, object value)
		{
			throw new NotImplementedException();
		}

		public override bool IsFixedSize
		{
			get { throw new NotImplementedException(); }
		}

		public override bool IsReadOnly
		{
			get { throw new NotImplementedException(); }
		}

		public override bool IsSynchronized
		{
			get { throw new NotImplementedException(); }
		}

		public override void Remove(object value)
		{
			throw new NotImplementedException();
		}

		public override void RemoveAt(string parameterName)
		{
			throw new NotImplementedException();
		}

		public override void RemoveAt(int index)
		{
			throw new NotImplementedException();
		}

		protected override void SetParameter(string parameterName, DbParameter value)
		{
			throw new NotImplementedException();
		}

		protected override void SetParameter(int index, DbParameter value)
		{
			throw new NotImplementedException();
		}

		public override object SyncRoot
		{
			get { throw new NotImplementedException(); }
		}
	}
}
